package com.epam.rentcar.utils;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Language extends HttpServlet{

	private static final long serialVersionUID = 1L;

	private static String language = "com.epam.rentcar.utils.locale_en_EN";

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String language = request.getParameter("lang");

		switch (language) {
		case "en":  Language.language = "com.epam.rentcar.utils.locale_en_EN";
		break;
		case "ru":  Language.language = "com.epam.rentcar.utils.locale_ru_RU";
		break;
		default: Language.language = "com.epam.rentcar.utils.locale_en_EN";
		break;
		}
		request.getRequestDispatcher("/main.jsp").forward(request, response);
	}

	public static String getLanguage() {
		return language;
	}

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}




}
